package com.ruoyi.scrb.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.scrb.domain.ScrbTc;
import com.ruoyi.scrb.service.IScrbTcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 特材公司生产日报录入Controller
 * 
 * @author lgx
 * @date 2022-09-22
 */
@RestController
@RequestMapping("/scrb/tc")
public class ScrbTcController extends BaseController
{
    @Autowired
    private IScrbTcService scrbTcService;

    /**
     * 查询特材公司生产日报录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:list')")
    @GetMapping("/list")
    public TableDataInfo list(ScrbTc scrbTc)
    {
        startPage();
        List<ScrbTc> list = scrbTcService.selectScrbTcList(scrbTc);
        return getDataTable(list);
    }

    /**
     * 导出特材公司生产日报录入列表
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:export')")
    @Log(title = "特材公司生产日报录入", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScrbTc scrbTc)
    {
        List<ScrbTc> list = scrbTcService.selectScrbTcList(scrbTc);
        ExcelUtil<ScrbTc> util = new ExcelUtil<ScrbTc>(ScrbTc.class);
        util.exportExcel(response, list, "特材公司生产日报录入数据");
    }

    /**
     * 获取特材公司生产日报录入详细信息
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:query')")
    @GetMapping(value = "/{cDate}")
    public AjaxResult getInfo(@PathVariable("cDate") String cDate)
    {
        return AjaxResult.success(scrbTcService.selectScrbTcByCDate(cDate));
    }

    /**
     * 新增特材公司生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:add')")
    @Log(title = "特材公司生产日报录入", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScrbTc scrbTc)
    {
        return toAjax(scrbTcService.insertScrbTc(scrbTc));
    }

    /**
     * 修改特材公司生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:edit')")
    @Log(title = "特材公司生产日报录入", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScrbTc scrbTc)
    {
        return toAjax(scrbTcService.updateScrbTc(scrbTc));
    }

    /**
     * 删除特材公司生产日报录入
     */
    @PreAuthorize("@ss.hasPermi('scrb:tc:remove')")
    @Log(title = "特材公司生产日报录入", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cDates}")
    public AjaxResult remove(@PathVariable String[] cDates)
    {
        return toAjax(scrbTcService.deleteScrbTcByCDates(cDates));
    }
}
